//
//  MoreViewController.m
//  享动
//
//  Created by lanou on 16/4/7.
//  Copyright © 2016年 HHUI. All rights reserved.
//

#import "MoreViewController.h"
#import "LoginViewController.h"
#import "MoreView.h"
#import "UserViewController.h"

@interface MoreViewController ()

@property (nonatomic, strong) MoreView *moreView;

@end

@implementation MoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _moreView = [[MoreView alloc] init];
    [_moreView.editData addTarget:self action:@selector(editDataAction:) forControlEvents:UIControlEventTouchUpInside];
    _moreView.naVc = self.navigationController;
    [self.view addSubview:_moreView];
    
    //self.toLoginButton = [UIButton buttonWithType:UIButtonTypeSystem];
    // Do any additional setup after loading the view.
}

#pragma mark --- 点击登录button 触发的方法 ---
- (IBAction)toLogin:(id)sender
{
    LoginViewController *loginVc = [[LoginViewController alloc] initWithNibName:@"login" bundle:[NSBundle mainBundle]];
    [self presentViewController:loginVc animated:YES completion:nil];
}

#pragma mark --- 点击编辑个人资料按钮触发的方法---
- (void)editDataAction:(UIButton *)sender
{
    // 创建CATransition对象
    CATransition *animation = [CATransition animation];
    
    animation.duration = 0;
    
    //设置运动type
    animation.type = kCATransitionFromRight;
    
    //设置运动速度
    animation.timingFunction = UIViewAnimationOptionCurveEaseInOut;
    
    [self.navigationController.view.layer addAnimation:animation forKey:nil];

    UserViewController *userVc = [[UserViewController alloc] initWithNibName:@"User" bundle:[NSBundle mainBundle]];

    [self.navigationController pushViewController:userVc animated:YES];
    
    __weak MoreViewController *blockSelf = self;
    
    userVc.userHeadImage = ^(UIImage *image){
        blockSelf.moreView.userHearImage.image = image;
    };
    userVc.userName = ^(NSString *name){
        blockSelf.moreView.userName.text = name;
    };
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
